package com.one.common.config;


import android.content.Context;

import com.one.common.utils.Logger;
import com.one.common.utils.SPUtils;
import com.one.common.utils.StringUtils;

import cn.jpush.android.api.JPushInterface;

/**
 * Author：zhulunjun
 * Time：2017/9/16
 * description： 本地持久化
 */

public class CPersisData {

    public static final String MOBILE = "mobile";
    public static final String IS_LOGIN = "is_login";//标识 用户是否登录过 ，登录过就可以复用session,退出操作设置false
    public static final String USER_INFO = "user_info";
    public static final String USER_STATE = "user_state";
    public static final String TRACK_INFO = "track_info";
    public static final String JPUSH_ID = "jpush_id";
    public static final String SESSION_ID = "session_id";
    public static final String APP_SOURCE = "app_source";
    public static final String LOCATION_INFO = "location_info";
    public static final String IS_FIRST = "is_first";

    public static final String IS_SHOW_GUIDE = "is_show_guide";
    /**
     * 选择车辆和司机的数据保存
     */
    public static final String SELECT_ID = "select_id";
    public static final String IS_SET_PWD = "is_set_pwd";
    /**
     * 是否在后台
     */
    public static final String IS_BACKGROUND = "is_background";


    /***
     * 是否存在需要跳转到   确认信息页面
     */
    public static final String NEED_TO_CHECKINFO = "need_to_checkinfo";

    public static String getTrackInfo() {
        return SPUtils.getString(TRACK_INFO, "");
    }

    public static void setTrackInfo(String trackInfo) {
        SPUtils.putString(TRACK_INFO, trackInfo);
    }

    public static String getSelectId() {
        return SPUtils.getString(SELECT_ID, "");
    }

    public static void setSelectId(String id) {
        SPUtils.putString(SELECT_ID, id);
    }

    public static boolean getIsBackground() {
        return SPUtils.getBoolean(IS_BACKGROUND, false);
    }

    public static void setIsBackround(boolean isBackround) {
        SPUtils.putBoolean(IS_BACKGROUND, isBackround);
    }


    public static boolean getNeedToCheckInfo() {
        return SPUtils.getBoolean(NEED_TO_CHECKINFO, false);
    }

    public static void setNeedToCheckInfo(boolean isBackround) {
        SPUtils.putBoolean(NEED_TO_CHECKINFO, isBackround);
    }

    public static boolean getIsSetPwd() {
        return SPUtils.getBoolean(IS_SET_PWD, false);
    }

    public static void setIsSetPwd(boolean isSetPwd) {
        SPUtils.putBoolean(IS_SET_PWD, isSetPwd);
    }

    public static boolean getIsLogin() {
        return SPUtils.getBoolean(IS_LOGIN, false);
    }

    public static void setIsLogin(boolean isLogin) {
        SPUtils.putBoolean(IS_LOGIN, isLogin);
    }


    public static boolean getIsGuide() {
        return SPUtils.getBoolean(IS_SHOW_GUIDE, true);
    }

    public static void setIsGuide(boolean isGuide) {
        SPUtils.putBoolean(IS_SHOW_GUIDE, isGuide);
    }


    public static boolean getIsFirst() {
        return SPUtils.getBoolean(IS_FIRST, true);
    }

    public static void setIsFirst(boolean isLogin) {
        SPUtils.putBoolean(IS_FIRST, isLogin);
    }

    public static String getUserInfo() {
        return SPUtils.getString(USER_INFO, "");
    }

    public static String getUserState() {
        return SPUtils.getString(USER_STATE, "");
    }

    public static void setUserState(String userState) {
        SPUtils.putString(USER_STATE, userState);
    }

    public static void setUserInfo(String userInfo) {
        SPUtils.putString(USER_INFO, userInfo);
    }

    public static void setLocationInfo(String locationInfo) {
        SPUtils.putString(LOCATION_INFO, locationInfo);
    }

    public static String getLocationInfo() {
        return SPUtils.getString(LOCATION_INFO, "");
    }

    public static String getJpushId() {
        return SPUtils.getString(JPUSH_ID, "");
    }

    public static void setJpushId(Context context) {
        String resId = JPushInterface.getRegistrationID(context);
        Logger.e("-------------------- resID " + resId);
        if (StringUtils.isNotBlank(resId)) {
            SPUtils.putString(JPUSH_ID, resId);
        }
    }

    public static String getMobile() {
        return SPUtils.getString(MOBILE, "");
    }

    public static void setMobile(String mobile) {
        SPUtils.putString(MOBILE, mobile);
    }

    public static String getSessionId() {
        return SPUtils.getString(SESSION_ID, "");
    }

    public static void setSessionId(String sessionId) {
        SPUtils.putString(SESSION_ID, sessionId);
    }

    public static String getAppSource() {
        return SPUtils.getString(APP_SOURCE, "");
    }

    public static void setAppSource(String appSource) {
        SPUtils.putString(APP_SOURCE, appSource);
    }
}
